import logging

from selenium.webdriver.common.by import By
from utils.base_aolai import BaseObject, BaseHandle
import time


class SetObject(BaseObject):
    def __init__(self):
        super().__init__()
        self.exit = (By.ID, 'com.yunmall.lc:id/setting_logout')
        self.right = (By.ID, 'com.yunmall.lc:id/ymdialog_right_button')
        self.address=(By.ID,'com.yunmall.lc:id/setting_address_manage')
    def findaddress(self):
        return self.search_ele(self.address)

    def findExit(self):
        return self.search_ele(self.exit)

    def findRight(self):
        return self.search_ele(self.right)


class SetHandle(BaseHandle):
    def __init__(self):
        self.so = SetObject()
    def address_click(self):
        self.so.findaddress().click()

    def swipe(self):
        self.move_all()

    def exit_click(self):
        logging.info("点击退出按钮")
        self.so.findExit().click()

    def right_click(self):
        logging.info("点击确认按钮")
        self.so.findRight().click()


class SetTask:
    logging.info("设置")
    sh = SetHandle()
    @classmethod
    def goto_address(cls):
        cls.sh.address_click()
    @classmethod
    def getOut(cls):
        cls.sh.move_all()
        time.sleep(1)
        cls.sh.exit_click()
        time.sleep(1)
        cls.sh.right_click()


